package test;

import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class Myfram03 extends JFrame implements KeyListener {
    public  Myfram03()
    {
        this.setSize(600,500);
        this.setAlwaysOnTop(true);
        this.setDefaultCloseOperation(3);
        this.setLayout(null);
        this.setLayout(null);
        this.setLocationRelativeTo(null);

        JButton jbt = new JButton();
        jbt.addKeyListener(this);
        this.getContentPane().add(jbt);
        this.setVisible(true);
    }

    @Override
    public void keyTyped(KeyEvent e) {

    }

    @Override
    public void keyPressed(KeyEvent e) {
        System.out.println("按下");
    }

    @Override
    public void keyReleased(KeyEvent e) {
        System.out.println("释放");
        int key = e.getKeyCode();
        System.out.println(key);
    }
}
